package com.devmindset.legoframework.usage.client.screen;

import com.devmindset.legoframework.client.layout.LegoScreenLayout;
import com.devmindset.legoframework.client.mvc.metadata.PlaceholderMapping;
import com.devmindset.legoframework.client.mvc.metadata.ScreenStory;
import com.devmindset.legoframework.client.mvc.metadata.Stories;
import com.devmindset.legoframework.client.screen.ApplicationScreen;
import com.devmindset.legoframework.client.screen.LegoPlaceholder;
import com.devmindset.legoframework.usage.client.component.FooterComponent;
import com.devmindset.legoframework.usage.client.component.OrganizerComponent;
import com.devmindset.legoframework.usage.client.component.OrganizerHeaderComponent;
import com.devmindset.legoframework.usage.client.text.UsageTexts;
import com.smartgwt.client.widgets.layout.Layout;

public class OrganizerScreen extends ApplicationScreen {
	
	private LegoScreenLayout screenLayout;
	
	private LegoPlaceholder header;
	private LegoPlaceholder main;
	private LegoPlaceholder footer;
	
	/** {@inheritDoc} */
	@Override
	protected Layout drawLayout() {
		screenLayout = new LegoScreenLayout();
		
		header = new LegoPlaceholder();
		header.setHeight(30);
		header.setWidth100();
		
		main = new LegoPlaceholder();
		main.setHeight100();
		main.setWidth100();
		
		footer = new LegoPlaceholder();
		footer.setHeight(30);
		footer.setWidth100();
		footer.setShowEdges(true);
		
		screenLayout.addMember(header);
		screenLayout.addMember(main);
		screenLayout.addMember(footer);
		
		return screenLayout;
	}
	
	/** {@inheritDoc} */
	protected String loadingMessage() {
		return UsageTexts.get().loadingFullScreenOrganizer();
	}
	
	/** {@inheritDoc} */
	@SuppressWarnings("unchecked")
	public ScreenStory myStory() {
		return Stories.screen()
			.consistsOf(
					new OrganizerHeaderComponent(),
					new OrganizerComponent(),
					new FooterComponent()
			)
			.initialState(
					new OrganizerHeaderComponent(),
					new OrganizerComponent(),
					new FooterComponent()
			)
			.placeholderMappings(
					new PlaceholderMapping(header, OrganizerHeaderComponent.class),
					new PlaceholderMapping(main, OrganizerComponent.class),
					new PlaceholderMapping(footer, FooterComponent.class)
			)
			.knownAs("Organizer Screen");
	}

}